<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="/WEB-INF/jsp/include/head.jsp"/>
</head>
<body>

<!-- 面包屑导航 -->
<ul class="breadcrumb">
    <li><strong>当前位置： </strong>系统管理</li>
    <li class="active">角色管理</li>
</ul>


<button id="toolbar" style="margin-left: 5px" type="button" class="btn btn-default"><span
        class="glyphicon glyphicon-plus-sign"></span>&nbsp;添加&nbsp;
</button>

<table id="table_data"></table>

<div class="modal fade" id="modal_ajax">
    <div class="modal-dialog  modal-mid ">
        <div class="modal-content ">
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<jsp:include page="/WEB-INF/jsp/include/footer.jsp"/>

<script>
        var $table_data = $('#table_data');
        $table_data.bootstrapTable({
            url: '<%=request.getContextPath()%>/upms/role/select',
            striped: true,
            cache: false,
            showRefresh: true,
            searchOnEnterKey: false,
            search: true,
            toolbar: "#toolbar",
            toolbarAlign: 'right',
            pagination: false,
            queryParams: function (params) {
                return params
            },
            columns: [
                {
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {
                    field: 'name',
                    title: '名称'
                }, {
                    field: 'remark',
                    title: '备注'
                },{
                    field: 'live',
                    title: '权限',
                    events: 'events',
                    formatter: function (value, row, index) {
                        return ['<button type="button"  class="btn btn-xs btn-default btn-success showPermission"><span class="glyphicon glyphicon-tree-deciduous"></span> 查看</button>'].join('');
                    }
                },
                {
                    field: 'live',
                    title: '状态',
                    formatter: function (value, row, index) {
                        var s= '<button type="button"  class="btn btn-xs btn-default btn-success">启 用</button>';
                        if (value==0){
                            s= '<button type="button"  class="btn btn-xs btn-default btn-danger">停 用</button>'
                        }
                        return [s].join('');
                    }
                }, {
                    title: '操作',
                    events: 'events',
                    formatter: function (value, row, index) {
                        return [
                            '<button type="button" class="btn btn-xs btn-default update-data">' +
                            '<span class="glyphicon glyphicon-edit  "></span> 修改' +
                            '</button>'
                        ].join('');
                    }
                }
            ]
        });
        window.events = {
            'click .update-data': function (e, value, row, index) {
                $('#modal_ajax').modal({
                    backdrop: 'static',
                    keyboard: false,
                    show: true,
                    remote: 'upms/role/editDlg?id='+row.id
                });
            },
            'click .showPermission': function (e, value, row, index) {
                $('#modal_ajax').modal({
                    backdrop: 'static',
                    keyboard: false,
                    show: true,
                    remote: 'upms/role/permissionDlg?id='+row.id
                });
            }
        };

        $("#toolbar").click(function () {
            $('#modal_ajax').modal({
                backdrop: 'static',
                keyboard: false,
                show: true,
                remote: 'upms/role/editDlg'
            });
        });

        $.sysPlugin.clearModalRemoveData("modal_ajax");

</script>


</body>
</html>